package com.qf.controller;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.qf.pojo.respVo.BaseResp;
import com.qf.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: 陌人不故
 * @Date: 2022/10/27/1:15
 */
@RestController
@RequestMapping("/teacher")
public class TeacherController {

    @Autowired
    TeacherService teacherService;


    @RequestMapping("/findAll")
    public BaseResp findAll(){
        return teacherService.findAll();
    }

    @RequestMapping("/findById")
    @HystrixCommand(fallbackMethod = "findByIdFallBack")
    public BaseResp findById(@RequestParam("id") Integer id){
        return teacherService.findById(id);
    }

    public BaseResp findByIdFallBack(@RequestParam("id") Integer id){
        return BaseResp.FAIL("教师服务出现异常!");
    }
}
